package com.ciwong.epaper.modules.epaper.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.ciwong.epaper.modules.epaper.bean.NewBook;
import com.ciwong.epaper.modules.epaper.ui.bookcase.ItemBookCase;
import com.ciwong.epaper.modules.epaper.util.ItemBookOrService;

/**
 * Created by Administrator on 2017/12/25.
 */

public class BookOrServiceAdapter extends BaseRvAdapter<RecyclerView.ViewHolder,ItemBookOrService,NewBook>{


    public BookOrServiceAdapter() {

    }


    @Override
    protected int getTopItemCount() {
        return 0;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BookOrServiceHolder(new ItemBookOrService(parent.getContext()));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        if (position < getDataList().size()) {
            ((BookOrServiceHolder)holder).itemBookOrService.update(getDataList().get(position));
        }

    }




    static class BookOrServiceHolder extends RecyclerView.ViewHolder {
        ItemBookOrService itemBookOrService;
        public BookOrServiceHolder(ItemBookOrService itemView) {
            super(itemView);
            itemBookOrService=itemView;
        }
    }

}
